" Vim 配置文件
" Author: Felix 
" Date: 2017
" Desc: web配置
" Plugin: vim-javascript,vim-jsbeautify, vim-node, vim-json, vim-easy-align, javascript-libraries-syntax,
"         html5, vim-closetag
" Key: c-s-f 格式化js/json/html
"

"echom "javascript配置"
" {{{ vim-javascript配置
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
let g:javascript_plugin_flow = 1
augroup javascript_folding
    au!
    au FileType javascript setlocal foldmethod=syntax
    map <leader>l :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1"<CR>
augroup END
"set foldmethod=syntax
"let g:javascript_conceal_function             = "ƒ"
"let g:javascript_conceal_null                 = "ø"
"let g:javascript_conceal_this                 = "@"
"let g:javascript_conceal_return               = "⇚"
"let g:javascript_conceal_undefined            = "¿"
"let g:javascript_conceal_NaN                  = "ℕ"
"let g:javascript_conceal_prototype            = "¶"
"let g:javascript_conceal_static               = "•"
"let g:javascript_conceal_super                = "Ω"
"let g:javascript_conceal_arrow_function       = "⇒"
" let g:javascript_conceal_noarg_arrow_function = "🞅" 
" let g:javascript_conceal_underscore_arrow_function = "🞅"
set conceallevel=1

" }}}


" {{{ vim-jsbeautify插件
autocmd FileType javascript noremap <buffer> <C-S-F> :call JsBeautify()<cr>
" for json
autocmd FileType json noremap <buffer> <C-S-F>  :call JsonBeautify()<cr>
" for jsx
autocmd FileType jsx noremap <buffer> <C-S-F>  :call JsxBeautify()<cr>
" for html
autocmd FileType html noremap <buffer> <C-S-F> :call HtmlBeautify()<cr>
" for css or scss
autocmd FileType css noremap <buffer> <C-S-F>  :call CSSBeautify()<cr>

autocmd FileType javascript vnoremap <buffer>  <C-S-F> :call RangeJsBeautify()<cr>
autocmd FileType json vnoremap <buffer> <C-S-F> :call RangeJsonBeautify()<cr>
autocmd FileType jsx vnoremap <buffer> <C-S-F> :call RangeJsxBeautify()<cr>
autocmd FileType html vnoremap <buffer> <C-S-F> :call RangeHtmlBeautify()<cr>
autocmd FileType css vnoremap <buffer> <C-S-F> :call RangeCSSBeautify()<cr>

" }}}

" 格式化xml
function! Xml()
    set filetype=xml
    :%s/></>\r</g  "把><替换成>回车<
    :normal gg=G<cr>
endfunction
nmap  ,ml  :call Xml()

" {{{ vim-json插件配置
let g:vim_json_syntax_conceal = 1
" }}}

" {{{ vim-node 插件配置


" }}}

" {{{ javascript-libraries-syntax配置
let g:used_javascript_libs = 'jquery,underscore,backbone,angularjs,requirejs,vue,react'
" autocmd BufReadPre *.js let b:javascript_lib_use_jquery = 1
" autocmd BufReadPre *.js let b:javascript_lib_use_underscore = 1
" autocmd BufReadPre *.js let b:javascript_lib_use_backbone = 1
" autocmd BufReadPre *.js let b:javascript_lib_use_prelude = 0
" autocmd BufReadPre *.js let b:javascript_lib_use_angularjs = 0

" }}}

"{{{vim-closetag

" filenames like *.xml, *.html, *.xhtml, ...
" These are the file extensions where this plugin is enabled.
"
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.xml'

" filenames like *.xml, *.xhtml, ...
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'

" filetypes like xml, html, xhtml, ...
" These are the file types where this plugin is enabled.
"
let g:closetag_filetypes = 'html,xhtml,phtml,xml'

" filetypes like xml, xhtml, ...
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filetypes = 'xhtml,jsx'

" integer value [0|1]
" This will make the list of non-closing tags case-sensitive (e.g. `<Link>` will be closed while `<link>` won't.)
"
let g:closetag_emptyTags_caseSensitive = 1

" Shortcut for closing tags, default is '>'
"
let g:closetag_shortcut = '>'

" Add > at current position without closing the current tag, default is ''
"
let g:closetag_close_shortcut = '<leader>>'

"}}}

"html自动输入匹配标签，输入>之后自动完成匹配标签
"au FileType xhtml,xml so html_autoclosetag.vim


